package com.sendemail;

import com.nz.net.hays.www.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MailSenderActivity extends Activity {

	TextView tv;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.apply);

        tv=(TextView)findViewById(R.id.jobDescription);
		
		Intent i=getIntent();
		String abt=i.getStringExtra("name");
		System.out.println(abt);
		tv.setText(abt);
        final Button send = (Button) this.findViewById(R.id.buttonApply);
        send.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

            	if(com.nz.net.hays.www.MainActivity.loginFlag==1)
            	{
            		Intent i = new Intent(getApplicationContext(), com.nz.net.hays.www.SignIn.class);
            		startActivity(i);
            		Toast.makeText(getApplicationContext(),"Please Sign In first.", Toast.LENGTH_LONG).show();
    				
            	}
            	else
            	{
                try {   
                    GMailSender sender = new GMailSender("deepak.ghai75@gmail.com", "itsgismo7390");
                    sender.sendMail("Job Application",   
                            "Congratulations!!! your job have been applied successfully.",   
                            "deepak.ghai75@gmail.com",   
                            "contact.bimalthapa85@gmail.com");   
                    Toast.makeText(getApplicationContext(),
    			            "Job Applied Successfully" , Toast.LENGTH_LONG)
    			            .show();
                } catch (Exception e) {   
                    Log.e("SendMail", e.getMessage(), e);   
                } 
            	}

            }
        });

    }
}